package com.example.consumerone.controller;

import com.example.common.base.Result;
import com.example.common.model.User;
import com.example.common.model.UserFeedback;
import com.example.consumerone.services.UserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.Map;

@Controller
@RequestMapping("/UserFeedback")
@CrossOrigin(origins = "${com.smart.origins}")
public class UserFeedbackController {

  @Autowired
  private UserFeedbackService userFeedbackService;


  @PostMapping("/add")
  public Result<?> add(@RequestParam UserFeedback userFeedback){
    return userFeedbackService.add(userFeedback);
  }

  @PostMapping("/save")
  public Result<?> saveFeedback(@RequestParam(value = "types") String types,
                        @RequestParam(value = "content") String content,
                        @RequestParam(value = "relation") String relation){
    Map<String,Object> saveFeedback = userFeedbackService.saveFeedback(types,content,relation);
    return Result.ok(saveFeedback);

  }
}
